<?php

use think\facade\Route;

/**
 * 路由分组：API
 * 注意：多级控制器的路径写法：目录.类
 * 参考（路由分组）：https://doc.thinkphp.cn/v8_0/route_group.html
 * 参考（多级目录）：https://doc.thinkphp.cn/v8_0/controller_define.html#%E5%A4%9A%E7%BA%A7%E6%8E%A7%E5%88%B6%E5%99%A8
 */
Route::group('api', function () {
   //json
   Route::get('json/test', 'api.json/test');

   //数据库
   Route::get('database/test', 'api.database/test');

   //restful
   Route::get('restful/list', 'api.restful/list');
   Route::get('restful/detail/:id', 'api.restful/detail');
   Route::post('restful/add', 'api.restful/add');
   Route::put('restful/update', 'api.restful/update');
   Route::delete('restful/delete/:id', 'api.restful/delete');
   //PS：如下两个路由会冲突，只会使用第一个路由，所以建议添加多级路由，如：restful/list
   // Route::get('restful','api.restful/list');
   // Route::get('restful/:id','api.restful/detail');

   //api文档
   Route::get('doc/list', 'api.doc/list');
   Route::get('doc/detail/:id', 'api.doc/detail');

   //模型
   Route::get('model/add', 'api.model/add');
   Route::get('model/update', 'api.model/update');
   Route::get('model/delete', 'api.model/delete');
   Route::get('model/list', 'api.model/list');
   Route::get('model/detail', 'api.model/detail');
   Route::get('model/detailWith', 'api.model/detailWith');
   Route::get('model/listWith', 'api.model/listWith');
});
